/*
 * Jobs.java
 * 
 * This file is part of Netuno Proteu.
 * 
 * CajuScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3, or (at your option) 
 * any later version.
 * 
 * CajuScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with CajuScript.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.netuno.proteu;

import org.apache.log4j.Logger;

/**
 * Session, verifies timeout of sessions and delete sessions expired
 * @author eduveks
 */
public class Jobs extends Thread {
    static Logger logger = Logger.getLogger(Jobs.class);
    /**
     * Session, verifies timeout of sessions and delete sessions expired
     */
    public Jobs() {

    }
    /**
     * Run
     */
    public void run() {
        while (true) {
            try {
                /*
                ServiceMonitor.timeout();
                String sessionsKeys = Config.sessions.getKeys(";");
                String[] mxSessionsKeys = null;
                if (sessionsKeys.indexOf(";") > -1) {
                    mxSessionsKeys = sessionsKeys.split(";");
                } else if (!sessionsKeys.equals("")) {
                    mxSessionsKeys = new String[1];
                    mxSessionsKeys[0] = sessionsKeys;
                }
                if (mxSessionsKeys != null) {
                    for (int x = 0; x < mxSessionsKeys.length; x++) {
                        try {
                            Values session = (Values) Config.sessions.get(mxSessionsKeys[x]);
                            if (System.currentTimeMillis() - Long.parseLong(session.getString("netuno_session_time")) > Config.getSessionTimeOut()) {
                                session.remove(mxSessionsKeys[x]);
                            }
                            session = null;
                        } catch (Exception e) {
                        }
                    }
                }
                sessionsKeys = null;
                mxSessionsKeys = null;
                */
            } catch (Exception e) {
                logger.error("Jobs error...", e);
            }
        }
    }
}
